package com.itheima.service.mongo.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.support.atomic.RedisAtomicLong;
import org.springframework.stereotype.Component;

@Component
public class RedisIDService {
    @Autowired
    private RedisTemplate redisTemplate;
    public Long getNextId(String collectionName){
        RedisAtomicLong redisAtomicLong = new RedisAtomicLong("id:" + collectionName, redisTemplate.getConnectionFactory());
        return redisAtomicLong.incrementAndGet();
    }

}
